package practice_3_4;
//给定一个非空整数数组，除了某个元素只出现一次以外，
//其余每个元素均出现两次。找出那个只出现了一次的元素。
public class NumAppearOnce {
    public static void main(String[] args) {
        int[] nums1 = new int[]{4,1,2,1,2};
        int[] nums2 = new int[]{8,1,2,1,2,12,14,7,14,12,7};

        System.out.println(numAppearOnce(nums1));

        System.out.println(numAppearOnce(nums2));
    }
    public static int numAppearOnce(int[] nums){
        int ret = 0;
        for(int num : nums){
            ret ^= num;
        }
        return ret;
    }
}
